<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCommodityActivityPurchaseRestrictionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commodity_activity_purchase_restriction', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('commodity_activity_id')->index('commodity_activity_id_index')->comment('商品活动 ID');

            $table->char('province', 16)->default('')->comment('省');
            $table->char('city', 16)->default('')->comment('市');
            $table->char('area', 16)->default('')->comment('区');
            $table->string('address', 128)->default('')->index()->comment('详细地址');

            $table->bigInteger('purchase_quantity')->default(0)->comment('购买数量');

            $table->index(['province', 'city', 'area'], 'province_city_area_index');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commodity_activity_purchase_restriction');
    }
}
